﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using BTv2.Controls;
using BTv2.UserControls;
using MahApps.Metro.Controls;

namespace BTv2
{
    /// <summary>
    /// Interaction logic for SensorTypeWindow.xaml
    /// </summary>
    public partial class SensorTypeWindow : MetroWindow
    {

        private SensorSettings _ss;
        public SensorTypeWindow()
        {
            InitializeComponent();
        }
        public SensorTypeWindow(SensorSettings ss)
        {
            InitializeComponent();
            _ss = ss;
        }


        private async void Create_Click(object sender, RoutedEventArgs e)
        {
            string type = SensorTypeTextbox.Text as string;
            await Task.Run(async () => {
                if (!SensorsController.GetInstance().SensorTypes.Keys.Any(k => k == type))
                {
                    await SensorsController.GetInstance().AddSensorType(type);
                }
            });
            this.Close();
        }

        private  void Cancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void ClosingTypeWindow(object sender, EventArgs e)
        {
            _ss.AttachTypeCreate();
            _ss.RefreshComboBoxes();
        }

    }
}
